home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / rdflib / syntax / parsers / RDFXMLParser.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.7 KB  |  36 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from rdflib.syntax.parsers import Parser
  5. from xml.sax import make_parser
  6. from xml.sax.saxutils import handler
  7. from xml.sax.handler import ErrorHandler
  8. from rdflib.syntax.parsers.RDFXMLHandler import RDFXMLHandler
  9.  
  10. def create_parser(store):
  11.     parser = make_parser()
  12.     parser.start_namespace_decl('xml', 'http://www.w3.org/XML/1998/namespace')
  13.     parser.setFeature(handler.feature_namespaces, 1)
  14.     rdfxml = RDFXMLHandler(store)
  15.     parser.setContentHandler(rdfxml)
  16.     parser.setErrorHandler(ErrorHandler())
  17.     return parser
  18.  
  19.  
  20. class RDFXMLParser(Parser):
  21.     
  22.     def __init__(self):
  23.         pass
  24.  
  25.     
  26.     def parse(self, source, sink, **args):
  27.         self._parser = create_parser(sink)
  28.         content_handler = self._parser.getContentHandler()
  29.         preserve_bnode_ids = args.get('preserve_bnode_ids', None)
  30.         if preserve_bnode_ids is not None:
  31.             content_handler.preserve_bnode_ids = preserve_bnode_ids
  32.         
  33.         self._parser.parse(source)
  34.  
  35.  
  36.